-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC method to count the number of TX in the host #1919
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
(one small comment to add)
go/host/storage/interfaces.go
Outdated
@@ -44,6 +44,8 @@ type BatchResolver interface { | |||
FetchBatchByHeight(height *big.Int) (*common.PublicBatch, error) | |||
// FetchTotalTxCount returns the number of transactions in the DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe explain in the comment the purpose of these 2 methods.
A fast but inaccurate one to be used for tenscan, and the other for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - except maybe distinguish a bit why the two methods are different (I guess the gist is you want a cached value because worried that row count is expensive but also want it to be ticking up for optics).
Personally I'm not sure the tx count should be persisted. If it's not been set in the last half hour or something it should query the count, and then in memory just count it up as batch txs come in. But this works for now so whatever's easier.
go/host/storage/interfaces.go
Outdated
@@ -44,6 +44,8 @@ type BatchResolver interface { | |||
FetchBatchByHeight(height *big.Int) (*common.PublicBatch, error) | |||
// FetchTotalTxCount returns the number of transactions in the DB | |||
FetchTotalTxCount() (*big.Int, error) | |||
// FetchTotalTxsQuery returns the number of transactions in the DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to give this a different comment to the one above imo, clarify why these two identical looking methods exist a bit haha.
Why this change is needed
Moray needs the true value of the tx count for the e2e tests so we can check for overflow.
https://github.com/ten-protocol/ten-internal/issues/3377
What changes were made as part of this PR
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks